package com.konsung.ksdc.manager.shop;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.konsung.ksdc.R;
import com.konsung.ksdc.bean.netbean.OrderItemNetBean;
import com.konsung.ksdc.bean.netbean.OrderProductNetBean;
import com.konsung.ksdc.manager.appmain.BaseActivity;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 评价详情
 * Created by DJH on 2017/3/3 0003.
 */

public class OrderEvaluateDetailActivity extends BaseActivity {
    @Bind(R.id.rl_back)
    RelativeLayout rlBack;
    @Bind(R.id.tab_tv_title)
    TextView tvTitle;
    @Bind(R.id.lv_product_list)
    ListView lvProductList;
    @Bind(R.id.rb_describe)
    RatingBar rbDescribe;
    @Bind(R.id.rb_service)
    RatingBar rbService;
    @Bind(R.id.tv_evaluate_time)
    TextView tvEvaluateTime;

    private List<OrderProductNetBean> productNetBeanList;
    private OrderItemNetBean orderItemNetBean;
    private EvaluateDetailAdapter evaluateDetailAdapter;

    @Override
    protected String activityDesc() {
        return getString(R.string.evaluate_detail);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_evaluate_detail);
        ButterKnife.bind(this);

        initData();
        initView();
    }

    /**
     * 初始化评价详情数据
     */
    private void initData() {
        productNetBeanList = getIntent().getParcelableArrayListExtra(OrderCommitOkActivity
                .BUY_LIST_DATA);
        orderItemNetBean = getIntent().getParcelableExtra(MyOrderActivity.ORDER_DATA);
        evaluateDetailAdapter = new EvaluateDetailAdapter(productNetBeanList);
        lvProductList.setAdapter(evaluateDetailAdapter);
    }

    /**
     * 初始化评价详情界面
     */
    private void initView() {
        tvTitle.setText(R.string.evaluate_detail);
        tvEvaluateTime.setText(orderItemNetBean.getEvaluateTime());
        rbDescribe.setRating(Float.parseFloat(orderItemNetBean.getEvaluateLevel()));
        rbService.setRating(Float.parseFloat(orderItemNetBean.getServerLevel()));
        rlBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
